home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>3.7.  Your script and its working</title>
- <link rel="stylesheet" href="gimp-help-plain.css" type="text/css" />
- <link rel="stylesheet" href="gimp-help-screen.css" type="text/css" />
- <link rel="stylesheet" href="gimp-help-custom.css" type="text/css" />
- <link rel="alternate stylesheet" href="gimp22.css" type="text/css" title="gimp22" />
- <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
- <link rel="start" href="index.html" title="GNU Image Manipulation Program" />
- <link rel="up" href="gimp-using-script-fu-tutorial.html" title="3.  A Script-Fu Tutorial" />
- <link rel="prev" href="gimp-using-script-fu-tutorial-extending-text-box.html" title="3.6.  Extending The Text Box Script" />
- <link rel="next" href="pt03.html" title="Part III.  Function Reference" />
- </head>
- <body>
- <div class="navheader">
- <table width="100%" summary="Navigation header">
- <tr>
- <th colspan="3" align="center">3.7. 
- <span lang="en" xml:lang="en">Your script and its working</span>
- </th>
- </tr>
- <tr>
- <td width="20%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html"><img src="../images/prev.png" alt="Prev" /></a> </td>
- <th width="60%" align="center">3. 
- <span lang="en" xml:lang="en">A Script-Fu Tutorial</span>
- </th>
- <td width="20%" align="right"> <a accesskey="n" href="pt03.html"><img src="../images/next.png" alt="Next" /></a></td>
- </tr>
- </table>
- <hr />
- </div>
- <div class="sect2" lang="en" xml:lang="en">
- <div class="titlepage">
- <div>
- <div>
- <h3 class="title"><a id="gimp-using-script-fu-tutorial-result"></a>3.7. 
- <span lang="en" xml:lang="en">Your script and its working</span>
- </h3>
- </div>
- </div>
- </div>
- <div class="sect3" lang="en" xml:lang="en">
- <div class="titlepage">
- <div>
- <div>
- <h4 class="title"><a id="id2620230"></a>3.7.1. 
- <span lang="en" xml:lang="en">What you write</span>
- </h4>
- </div>
- </div>
- </div>
- <p>Below the complete script:</p>
- <pre class="programlisting">
- (script-fu-register
- "script-fu-text-box" ;func name
- "Text Box" ;menu label
- "Creates a simple text box, sized to fit\
- around the user's choice of text,\
- font, font size, and color." ;description
- "Michael Terry" ;author
- "copyright 1997, Michael Terry" ;copyright notice
- "October 27, 1997" ;date created
- "" ;image type that the script works on
- SF-STRING "Text:" "Text Box" ;a string variable
- SF-FONT "Font:" "Charter" ;a font variable
- SF-ADJUSTMENT "Font size" '(50 1 1000 1 10 0 1)
- ;a spin-button
- SF-COLOR "Color:" '(0 0 0) ;color variable
- SF-ADJUSTMENT "Buffer amount" '(35 0 100 1 10 1 0)
- ;a slider
- )
- (script-fu-menu-register "script-fu-text-box" "<Toolbox>/Xtns/Script-Fu/Text")
- (define (script-fu-text-box inText inFont inFontSize inTextColor inBufferAmount)
- (let*
- (
- ; define our local variables
- ; create a new image:
- (theImageWidth 10)
- (theImageHeight 10)
- (theImage)
- (theImage
- (car
- (gimp-image-new
- theImageWidth
- theImageHeight
- RGB
- )
- )
- )
- (theText) ;a declaration for the text
- (theBuffer) ;create a new layer for the image
- (theLayer
- (car
- (gimp-layer-new
- theImage
- theImageWidth
- theImageHeight
- RGB-IMAGE
- "layer 1"
- 100
- NORMAL
- )
- )
- )
- ) ;end of our local variables
- (gimp-image-add-layer theImage theLayer 0)
- (gimp-context-set-background '(255 255 255) )
- (gimp-context-set-foreground inTextColor)
- (gimp-drawable-fill theLayer BACKGROUND-FILL)
- (set! theText
- (car
- (gimp-text-fontname
- theImage theLayer
- 0 0
- inText
- 0
- TRUE
- inFontSize PIXELS
- "Sans")
- )
- )
- (set! theImageWidth (car (gimp-drawable-width theText) ) )
- (set! theImageHeight (car (gimp-drawable-height theText) ) )
- (set! theBuffer (* theImageHeight (/ inBufferAmount 100) ) )
- (set! theImageHeight (+ theImageHeight theBuffer theBuffer) )
- (set! theImageWidth (+ theImageWidth theBuffer theBuffer) )
- (gimp-image-resize theImage theImageWidth theImageHeight 0 0)
- (gimp-layer-resize theLayer theImageWidth theImageHeight 0 0)
- (gimp-layer-set-offsets theText theBuffer theBuffer)
- (gimp-display-new theImage)
- (list theImage theLayer theText)
- )
- )
- </pre>
- </div>
- <div class="sect3" lang="en" xml:lang="en">
- <div class="titlepage">
- <div>
- <div>
- <h4 class="title"><a id="id2620410"></a>3.7.2. What you obtain</h4>
- </div>
- </div>
- </div>
- <div class="figure">
- <a id="id2620417"></a>
- <p class="title">
- <b>Figure 12.5. 
- <span lang="en" xml:lang="en">And the result on the screen.</span>
- </b>
- </p>
- <div class="figure-contents">
- <div class="mediaobject">
- <img src="../images/using/script-fu-screen.png" alt="And the result on the screen." />
- </div>
- </div>
- </div>
- <br class="figure-break" />
- </div>
- </div>
- <div class="navfooter">
- <hr />
- <table width="100%" summary="Navigation footer">
- <tr>
- <td width="40%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html"><img src="../images/prev.png" alt="Prev" /></a> </td>
- <td width="20%" align="center">
- <a accesskey="u" href="gimp-using-script-fu-tutorial.html">
- <img src="../images/up.png" alt="Up" />
- </a>
- </td>
- <td width="40%" align="right"> <a accesskey="n" href="pt03.html"><img src="../images/next.png" alt="Next" /></a></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html">3.6. 
- <span lang="en" xml:lang="en">Extending The Text Box Script</span>
- </a> </td>
- <td width="20%" align="center">
- <a accesskey="h" href="index.html">
- <img src="../images/home.png" alt="Home" />
- </a>
- </td>
- <td width="40%" align="right" valign="top"> <a accesskey="n" href="pt03.html">Part III. 
- <span lang="en" xml:lang="en">
- Function Reference
- </span>
- </a></td>
- </tr>
- </table>
- </div>
- </body>
- </html>
-